import { legacy_createStore as createStore } from 'redux';

const initState = { count: 100, msg: '123', title: '123' };

function countReducer(state = initState, action) {
  console.warn('action  ----->  ', action, state);

  switch (action.type) {
    case 'add':
      return { count: state.count + action.payload };

    case 'des':
      return { count: state.count - action.payload };

    default:
      return state;
  }
}

const store = createStore(countReducer);
export default store;

export function addAction(payload) {
  return {
    type: 'add',
    payload,
  };
}

// enf
export const desAction = (payload) => {
  return {
    type: 'des',
    payload,
  };
};
